<template>
	<!-- 项目 -->
	<view class="upload">
		<uniTabs :tabs="tabs" :activeTab="activeTab" lineHeight="false" @change="change" activeColor="#DD524D"
			class="tabs"></uniTabs>
		<view v-if="account_type =='劳务企业'">
			<view class="" v-if="activeTab==0">
				<view class="footer" v-for="(item,index) in projectList">
					<view class="first-line">
						<text class="ttt"> {{item.project_name}}</text>
					</view>
					<view class="sec-line">
						<text class="ccc">项目编号：{{item.name}}</text>
					</view>
						<text class="ccc">项目经理：{{item.manager}}</text>
					<text class="ccc">{{item.begin_date}}至{{item.end_date}}</text>
				</view>
			<image v-if="projectList.length<1"  style="position: absolute;top:0;left: 0;bottom: 0;right: 0;margin: auto;width: 600rpx;" src="../../../static/image/no-data.png" mode=""></image>
			</view>
		</view>
		<view v-if="account_type=='工程企业'" class="company-project">
			<view class="engineering-content" v-if="activeTab==0">
				<view class="top" v-for="(item,index) in buildingList">
					<view class="first-line">
						<text class="title-text">{{item.project_type}}</text>
						<text class="ttt"> {{item.project_name}}</text>
					</view>
					<view class="sec-line">
						<text class="ccc">项目编号：{{item.name}}</text>
					</view>
                     <text class="ccc">项目经理：{{item.manager}}</text>
					<text class="ccc">{{item.begin_date}}至{{item.end_date}}</text>
				</view>
				<image v-if="buildingList.length<1"  style="position: absolute;top:0;left: 0;bottom: 0;right: 0;margin: auto;width: 600rpx;" src="../../../static/image/no-data.png" mode=""></image>
			</view>

			<view class="engineering-content" v-if="activeTab==1">
				<view class="footer" v-for="(item,index) in readyList">
					<view class="first-line">
						<text class="title-text">{{item.project_type}}</text>
						<text class="ttt"> {{item.project_name}}</text>
					</view>
					<view class="sec-line">
						<text class="ccc">项目编号：{{item.name}}</text>
					</view>
						<text class="ccc">项目经理：{{item.manager}}</text>
					<text class="ccc">{{item.begin_date}}至{{item.end_date}}</text>
				</view>
				<image v-if="readyList.length<1"  style="position: absolute;top:0;left: 0;bottom: 0;right: 0;margin: auto;width: 600rpx;" src="../../../static/image/no-data.png" mode=""></image>
			</view>
		</view>

	</view>
</template>

<script>
	import uniTabs from '@/components/v-tabs/v-tabs.vue'
	import api from '@/static/js/api.js'
	export default {
		components: {
			uniTabs
		},

		data() {
			return {
				peopletabs: [
					// '当前项目',
					'往期项目'
				],
				labortabs: [
					'在建项目',
					'完工项目'
				],
				activeTab: 0,
				account_type: '',
				tabs: '',
				personInfo: '',
				buildingList:[],
				readyList:[],
				projectList:[]
			}
		},
		onShow() {
			this.personInfo = JSON.parse(uni.getStorageSync('userInfo'))
			this.account_type = this.personInfo.account_type
			this.tabs = this.account_type == '劳务企业' ? this.peopletabs : this.labortabs
			this.engineeringMethod()
		},
		methods: {
			change(index) {
				this.activeTab = index
				this.engineeringMethod()
			},
            engineeringMethod(){
				let domain = "['|', ('users_ids', 'in', [" + this.personInfo.uid + "]), ('company_id.user_id', '=', " + this.personInfo.uid +")]"
				api.companyProject('jhj.project', '_api_page', this.personInfo.access_token,domain,'','','','id desc', this.personInfo.uid,
					this.personInfo.partner_id, 1000, 1).then(res => {
					this.buildingList = res.data.filter(v=> v.state=='在建')
					console.log(this.buildingList)
					this.readyList = res.data.filter(v=> v.state !='在建')
					this.projectList = res.data
				}).catch(e => {
					uni.showToast({
						icon: 'none',
						title: e.message
					})
				})
				
			}
			
		}

	}
</script>

<style lang="less" scoped>
	.upload {
		width: 100%;
		height: 100vh;
		background-color: #EBEEF5;
	}

	.tabs {
		position: relative;
	}
.engineering-content{
	margin-bottom: 10rpx 10rpx;
}
	/deep/ .v-tabs {
		width: 100%;
		height: 100rpx;
		background-color: #FFFFFF;
		line-height: 100rpx;
	}

	/deep/ .v-tabs__container-item {
		// width: 50%;
		justify-content: center;
		margin: 0 auto;
	}

	.top {
		margin-top: 20rpx;
		background-color: #FFFFFF;

		text {
			display: block;
		}

		.ttt {
			font-size: 30rpx;
			padding: 15rpx 40rpx;
		}

		.ccc {
			font-size: 28rpx;
			padding: 15rpx 40rpx;
			color: #808080;
		}

		.top-tab {
			display: flex;
			justify-content: space-between;

			p {
				width: 50%;
				border: 1px solid #DCDCDC;
				padding: 15rpx;
				text-align: center;
			}

			p:nth-child(1) {
				border-right: none;
				color: #1E90FF;
			}

			p:nth-child(2) {
				border-right: none;
				color: #FFD700;
			}

		}

	}

	.footer {
		margin-top: 20rpx;
		background-color: #FFFFFF;
		text {
			display: block;
		}

		.ttt {
			font-size: 30rpx;
			padding: 15rpx 40rpx;
		}

		.ccc {
			font-size: 28rpx;
			padding: 15rpx 40rpx;
			color: #808080;
		}
	}

	.company-project {
		.top {
			margin-top: 20rpx;
			background-color: #FFFFFF;

			.first-line {
				display: flex;
				width: 90%;

				.title-text {
					background-color: #1E90FF;
					color: #FFFFFF;
					height: 40rpx;
					margin-top: 15rpx;
					margin-left: 40rpx;
					border-radius: 10rpx;
				}

				.ttt {
					font-size: 30rpx;
				}
			}

			.sec-line {
				display: flex;

				.ccc {
					font-size: 28rpx;
					padding: 15rpx 40rpx;
					color: #808080;
				}
			}

			text {
				display: block;
			}
		}

		.footer {
			margin-top: 20rpx;
			background-color: #FFFFFF;

			.first-line {
				display: flex;
				width: 90%;

				.title-text {
					background-color: #1E90FF;
					color: #FFFFFF;
					height: 40rpx;
					margin-top: 15rpx;
					margin-left: 40rpx;
					border-radius: 10rpx;
				}

				.ttt {
					font-size: 30rpx;
				}
			}

			.sec-line {
				display: flex;

				.ccc {

					font-size: 28rpx;
					padding: 15rpx 40rpx;
					color: #808080;
				}
			}

			text {
				display: block;
			}
		}
	}
</style>
